package com.fish.passport.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fish.common.constant.QueryPage;
import com.fish.common.dao.BaseIbatisDao;
import com.fish.passport.po.PassProvider;
import com.fish.product.po.PerformTarget;

/**
 * @author clj
 */
@SuppressWarnings("unchecked")
public class PassProviderDAO extends BaseIbatisDao {
	
	public PassProvider selectByPerformTargetId(String performTargetId) {
		List<PassProvider> list = super.getSqlMapClientTemplate().queryForList(
				"PASS_PROVIDER.selectByPerformTargetId", performTargetId);
		if (list!=null && list.size()>0) {
			return list.get(0);
		}
		return null;
	}
	
	/**
	 * 按条件查询
	 * 
	 * @param 查询参数
	 */
	public List<PassProvider> queryProviderByParams(String providerName) {
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("providerName", providerName);
		return super.getSqlMapClientTemplate().queryForList(
				"PASS_PROVIDER.queryProviderByParams", params);
	}

	/**
	 * 新增
	 * 
	 * @param PassProvider对象
	 */
	public void addPassProvider(PassProvider passProvider) {
		super.getSqlMapClientTemplate().insert(
				"PASS_PROVIDER.insertPassProvider", passProvider);
	}

	/**
	 * 修改
	 */
	public void updatePassProvider(PassProvider passProvider) {
		super.getSqlMapClientTemplate().update(
				"PASS_PROVIDER.updatePassProvider", passProvider);
	}

	/**
	 * 删除
	 */
	public void deletePassProvider(Integer providerId) {
		super.getSqlMapClientTemplate().delete(
				"PASS_PROVIDER.deletePassProvider", providerId);
	}
	public PassProvider getPassProviderById(Integer providerId) {
		return (PassProvider)super.getSqlMapClientTemplate().queryForObject(
				"PASS_PROVIDER.getPassProviderById", providerId);
	}
	
	public Long queryPassProviderCountByObject(PassProvider passProvider){
		return  (Long) this.getSqlMapClientTemplate().queryForObject("PASS_PROVIDER.countPassProviderWithPaging", passProvider);
	}
	
	public  List<PassProvider> queryPassProviderObject(PassProvider passProvider,QueryPage queryPage){
		passProvider.setBeginItem(queryPage.getBeginItem());
		passProvider.setEndItem(queryPage.getPageSize());
		return (List<PassProvider>) this.getSqlMapClientTemplate().queryForList("PASS_PROVIDER.selectPassProviderWithPaging", passProvider);
	}
}
